package com.prs.crm.action;



import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.courser.struts.BaseAction;
import org.courser.ui.PaginationSupport;
import org.hibernate.criterion.DetachedCriteria;


import com.prs.crm.annotation.Clew;
import com.prs.crm.domain.Teacher;

import com.prs.crm.service.TeacherService;

public class TeacherAction extends BaseAction {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private TeacherService teacherService;
	private PaginationSupport pagination;
	public Teacher teacher;

	public Teacher getTeacher() {
		return teacher;
	}

	public void setTeacher(Teacher teacher) {
		this.teacher = teacher;
	}

	public PaginationSupport getPagination() {
		return pagination;
	}

	public void setPagination(PaginationSupport pagination) {
		this.pagination = pagination;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public TeacherService getTeacherService() {
		return teacherService;
	}

	public void setTeacherService(TeacherService teacherService) {
		this.teacherService = teacherService;
	}

	@Action( "testlist")
	public String testlist() {

		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				Teacher.class);
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getTeacherService().listByPage(criteria,
				pagination));
		return SUCCESS;
	}

	@Clew(results = { "success", "none" })
	@Action(value = "saveTeacher", results = {
			@Result(name = "success", type = "redirect", location = "testlist"),
			@Result(name = "none", type = "redirect", location = "testlist") })
	public String saveTeacher() {

		this.getTeacherService().save(teacher);
		return SUCCESS;
	}
	/*@Clew(results = { "success", "none" })
	@Action(value = "gosaveTeacher", results = {
			@Result(name = "success", type = "redirect", location = "/saveTeacher.ftl"),
			@Result(name = "none", type = "redirect", location = "testlist") })
	public String gosaveTeacher(){
		return SUCCESS;
	}*/
	
}
